//
//  ContentView2.swift    ← 建议改成一个全新文件名
//  BounceDemo
//
//  Created 2025/5/17
//
import SwiftUI
import CoreHaptics


// MARK: - 视图调用示例
struct ContentView2: View {
    @EnvironmentObject var haptic: AdvancedHapticManager
    
    var body: some View {
        VStack(spacing: 20) {
            Button("操作成功 ✅") {
                haptic.playStandard(.success)
            }
            
            Button("出现警告 ⚠️") {
                haptic.playStandard(.warning)
            }
            
            Button("发生错误 ❌") {
                haptic.playStandard(.error)
            }
            
            Button("自定义震动1") {
                let customEvent = CHHapticEvent(
                    eventType: .hapticContinuous,
                    parameters: [
                        CHHapticEventParameter(parameterID: .hapticIntensity, value: 0.5),
                        CHHapticEventParameter(parameterID: .hapticSharpness, value: 0.3)
                    ],
                    relativeTime: 0,
                    duration: 3.0
                )
                haptic.playPattern([customEvent])
            }
            Button("自定义震动2") {
                haptic.playIntensityCurveEffect();
            }
            
           
        }
        .buttonStyle(.borderedProminent)
        .padding()
    }
}
